package com.example.zjx8969.myapplication.compare;

import androidx.room.Embedded;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import android.content.Context;
import androidx.annotation.NonNull;
import android.text.TextUtils;


/**
 * Created by wjj3771 on 2017/11/29.
 */
@Entity(tableName = "sdkControl")
public class SDKInfo {
    @PrimaryKey
    @NonNull
    public String key;
    @Ignore
    public static final int SDK_DISABLE = 0;
    @Ignore
    public static final int SDK_ENABLE = 1;
    public int state;
    @Embedded
    public ControlExtra extra;

    public ControlExtra getControlExtra() {

        return extra;
    }

    public void setControlExtra(ControlExtra controlExtra) {
        this.extra = controlExtra;
    }

    public void setState(int state) {
        this.state = state;
    }

    private int getSDKState() {
        if (extra != null && !TextUtils.isEmpty(extra.crashInfo)) {
            return SDK_DISABLE;
        } else
            return state;

    }

    public boolean isSDKEnable(Context context, String sdkName) {
        return getSDKState() == SDK_ENABLE;
    }


}
